{include file="header.php"}

<h2>User List</h2>

<ul class="toolbar clearfix">
	<li><a class="link-button" href="{$site_url}?controller=user&action=add">Add</a></li>
</ul>

<script type="text/javascript">
function confirmDelete(id)
{
	var answer = confirm('Are your sure you want to delete this record? This action cannot be undone.');
	
	if (answer) {
		window.location = '{$site_url}?controller=user&action=del&id=' + id;
	}
}
</script>

<table>
	<thead>
		<tr>
			<th width="30">ID</th>
			<th>Username</th>
			<th>Firstname</th>
			<th>Lastname</th>
			<th>E-mail</th>
			<th>Actions</th>
		</tr>
	</thead>
	<tbody>
		{if $users}
		{foreach $users as $user}
		<tr>
			<td><a href="{$site_url}?controller=user&action=view&id={$user.id}">{$user.id}</a></td>
			<td><a href="{$site_url}?controller=user&action=view&id={$user.id}">{$user.username}</a></td>
			<td><a href="{$site_url}?controller=user&action=view&id={$user.id}">{$user.firstname}</a></td>
			<td><a href="{$site_url}?controller=user&action=view&id={$user.id}">{$user.lastname}</a></td>
			<td><a href="{$site_url}?controller=user&action=view&id={$user.id}">{$user.email}</a></td>
			<td class="actions">
				<a class="link-button link-button-green" href="{$site_url}?controller=user&action=edit&id={$user.id}">Edit</a>
				<a class="link-button link-button-red" onclick="confirmDelete({$user.id})" href="#">Delete</a>
			</td>
		</tr>
		{/foreach}
		{else}
		<tr>
			<td colspan="5">Hmm... not record to show.</td>
		</tr>
		{/if}
	</tbody>
</table>

{include file="footer.php"}